home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / include / RCS / misc.h,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  4.7 KB  |  175 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.16.17.21;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/***********************************************************
  27. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  28. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  29.  
  30.                         All Rights Reserved
  31.  
  32. Permission to use, copy, modify, and distribute this software and its 
  33. documentation for any purpose and without fee is hereby granted, 
  34. provided that the above copyright notice appear in all copies and that
  35. both that copyright notice and this permission notice appear in 
  36. supporting documentation, and that the names of Digital or MIT not be
  37. used in advertising or publicity pertaining to distribution of the
  38. software without specific, written prior permission.  
  39.  
  40. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  41. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  42. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  43. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  44. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  45. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  46. SOFTWARE.
  47.  
  48. ******************************************************************/
  49. /* $XConsortium: misc.h,v 1.53 89/07/18 13:33:56 rws Exp $ */
  50. #ifndef MISC_H
  51. #define MISC_H 1
  52. /*
  53.  *  X internal definitions 
  54.  *
  55.  */
  56.  
  57.  
  58. extern unsigned long globalSerialNumber;
  59. extern unsigned long serverGeneration;
  60.  
  61. #ifndef NULL
  62. #if __STDC__ && !NOSTDHDRS
  63. #include <stddef.h>
  64. #else
  65. #define NULL            0
  66. #endif
  67. #endif
  68.  
  69. #define MAXSCREENS    3
  70. #define MAXCLIENTS    128
  71. #define MAXFORMATS    8
  72. #define MAXVISUALS_PER_SCREEN 50
  73.  
  74. typedef unsigned char *pointer;
  75. typedef int Bool;
  76. typedef unsigned long PIXEL;
  77. typedef unsigned long ATOM;
  78.  
  79.  
  80. #ifndef TRUE
  81. #define TRUE 1
  82. #define FALSE 0
  83. #endif
  84. #include "os.h"     /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
  85.  
  86. #define NullBox ((BoxPtr)0)
  87. #define MILLI_PER_MIN (1000 * 60)
  88. #define MILLI_PER_SECOND (1000)
  89.  
  90.     /* this next is used with None and ParentRelative to tell
  91.        PaintWin() what to use to paint the background. Also used
  92.        in the macro IS_VALID_PIXMAP */
  93.  
  94. #define USE_BACKGROUND_PIXEL 3
  95. #define USE_BORDER_PIXEL 3
  96.  
  97.  
  98. /* byte swap a long literal */
  99. #define lswapl(x) ((((x) & 0xff) << 24) |\
  100.            (((x) & 0xff00) << 8) |\
  101.            (((x) & 0xff0000) >> 8) |\
  102.            (((x) >> 24) & 0xff))
  103.  
  104. /* byte swap a short literal */
  105. #define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
  106.  
  107. #define min(a, b) (((a) < (b)) ? (a) : (b))
  108. #define max(a, b) (((a) > (b)) ? (a) : (b))
  109. #define abs(a) ((a) > 0 ? (a) : -(a))
  110. #define fabs(a) ((a) > 0.0 ? (a) : -(a))    /* floating absolute value */
  111. #define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
  112. /*
  113.  * return the least significant bit in x which is set
  114.  *
  115.  * This works on 1's complement and 2's complement machines.
  116.  * If you care about the extra instruction on 2's complement
  117.  * machines, change to ((x) & (-(x)))
  118.  */
  119. #define lowbit(x) ((x) & (~(x) + 1))
  120.  
  121. #define MAXSHORT 32767
  122. #define MINSHORT -MAXSHORT 
  123.  
  124.  
  125. /* some macros to help swap requests, replies, and events */
  126.  
  127. #define LengthRestB(stuff) \
  128.     (((unsigned long)stuff->length << 2) - sizeof(*stuff))
  129.  
  130. #define LengthRestS(stuff) \
  131.     (((unsigned long)stuff->length << 1) - (sizeof(*stuff) >> 1))
  132.  
  133. #define LengthRestL(stuff) \
  134.     ((unsigned long)stuff->length - (sizeof(*stuff) >> 2))
  135.  
  136. #define SwapRestS(stuff) \
  137.     SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
  138.  
  139. #define SwapRestL(stuff) \
  140.     SwapLongs((long *)(stuff + 1), LengthRestL(stuff))
  141.  
  142. /* byte swap a long */
  143. #define swapl(x, n) n = ((char *) (x))[0];\
  144.          ((char *) (x))[0] = ((char *) (x))[3];\
  145.          ((char *) (x))[3] = n;\
  146.          n = ((char *) (x))[1];\
  147.          ((char *) (x))[1] = ((char *) (x))[2];\
  148.          ((char *) (x))[2] = n;
  149.  
  150. /* byte swap a short */
  151. #define swaps(x, n) n = ((char *) (x))[0];\
  152.          ((char *) (x))[0] = ((char *) (x))[1];\
  153.          ((char *) (x))[1] = n
  154.  
  155. /* copy long from src to dst byteswapping on the way */
  156. #define cpswapl(src, dst) \
  157.                  ((char *)&(dst))[0] = ((char *) &(src))[3];\
  158.                  ((char *)&(dst))[1] = ((char *) &(src))[2];\
  159.                  ((char *)&(dst))[2] = ((char *) &(src))[1];\
  160.                  ((char *)&(dst))[3] = ((char *) &(src))[0];
  161.  
  162. /* copy short from src to dst byteswapping on the way */
  163. #define cpswaps(src, dst)\
  164.          ((char *) &(dst))[0] = ((char *) &(src))[1];\
  165.          ((char *) &(dst))[1] = ((char *) &(src))[0];
  166.  
  167. extern void SwapLongs();
  168. extern void SwapShorts();
  169.  
  170. typedef struct _DDXPoint *DDXPointPtr;
  171. typedef struct _Box *BoxPtr;
  172.  
  173. #endif /* MISC_H */
  174. @
  175.